const datefmt = (t, format = 'YYYY-MM-DD HH:mm:ss') => {
    const config = {
        YYYY: t.getFullYear(),
        MM: (t.getMonth() + 1).toString().padStart(2, '0'),
        DD: t.getDate().toString().padStart(2, '0'),
        HH: t.getHours().toString().padStart(2, '0'),
        mm: t.getMinutes().toString().padStart(2, '0'),
        ss: t.getSeconds().toString().toString().padStart(2, '0')
    };
    for (const key in config) {
        format = format.replace(key, config[key]);
    }
    return format;
}

module.exports = {
    datefmt
}